urlChecker = {

	removeErrors : function(id) {
		var errors = $(id);
		if (errors != null) {
			errors.empty();
		}
	},

	checkUrlProtocol : function(url) {
		return url.search("^http://|https://|svn://");
	},

	checkUrl : function() {
		this.removeErrors("errors");
		var urlField = $('input[name=svnUrl]');
		var url = urlField.val();
		if (url == null || url == '' || this.checkUrlProtocol(url) != 0) {
			alert("Url is not valid");
			urlField.focus();
			return false;
		}
		return true;
	},

	onSubmitHandler : function() {
		$('#svnUrlForm').submit(function() {
			return urlChecker.checkUrl();
		});
	}
};

$(document).ready(function() {
	urlChecker.onSubmitHandler();
});